{include file="public/header" /}
<div class="header" style="margin-bottom:20px;">
	<span>项目配置</span>
	<a href="{$config['admin_route']}Core/configlist">
		<span style="background:#999;">配置管理</span>
	</a>
	<div></div>
</div>
<form class="layui-form">
	{foreach($lists as $lists_v)}
		{if($lists_v['config_type'] == 1)}
			<div class="layui-form-item">
				<label class="layui-form-label">{$lists_v['config_info']}</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="{$lists_v['config_name']}" name="{$lists_v['config_name']}" placeholder="{$lists_v['config_desc']}" value="{$lists_v['config_value']}">
				</div>
				<div class="layui-form-mid layui-word-aux">{$lists_v['config_desc']}</div>
			</div>
		{elseif($lists_v['config_type'] == 2)/}
			<div class="layui-form-item">
				<label class="layui-form-label">{$lists_v['config_info']}</label>
				<div class="layui-input-inline">
					<button type="button" class="layui-btn" id="{$lists_v['config_name']}">上传图片</button>
				</div>
				<div class="layui-form-mid layui-word-aux">{$lists_v['config_desc']}</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">{$lists_v['config_info']}预览</label>
				<div class="layui-input-block">
					<div class="layui-upload-list" id="yulan_{$lists_v['config_name']}" style="width:90%;float:left;">
						{if !empty($lists_v['config_value'])}
							<div class="upload_pic_li" style="position:relative;width:100px;float:left;margin:0 10px 10px 0">
								<img style="width:100px;height:100px;" src="{$lists_v['config_value']}" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()">
								<input type="hidden" name="{$lists_v['config_name']}" value="{$lists_v['config_value']}"/>
							</div>
						{/if}
					</div>
				</div>
			</div>
			<script type="text/javascript">
				layui.use(['layer','upload'],function(){
					layer = layui.layer;		// layui 弹框
					upload = layui.upload;		// layui 上传
					$ = layui.jquery;			// layui jquery

					upload.render({
						elem: "#{$lists_v['config_name']}",
						url: "{$config['admin_route']}index/upload_img",
						multiple: true,
						done: function(res,title){
							if(res.code > 0){
								return layer.msg("上传失败，"+res.msg);
							}else{
								$("#yulan_{$lists_v['config_name']}").html('<div class="upload_pic_li" style="position:relative; width:100px; float:left; margin:0 10px 10px 0"><img style="width:100px;height:100px;" src="'+ res.url +'" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()"><input type="hidden" name="{$lists_v['config_name']}" value="'+res.data+'"/></div>');
							}
						}
					});
				})
			</script>
		{elseif($lists_v['config_type'] == 3)/}
			<div class="layui-form-item">
				<label class="layui-form-label">{$lists_v['config_info']}</label>
				<div class="layui-input-block">
					<textarea class="layui-textarea" id="{$lists_v['config_name']}" name="{$lists_v['config_name']}" placeholder="{$lists_v['config_desc']}">{$lists_v['config_value']}</textarea>
				</div>
			</div>
		{/if}
	{/foreach}
</form>
<div class="layui-form-item" style="margin:50px 0 0;text-align:center;">
	<button type="button" class="layui-btn layui-btn layui-btn-lg" onclick="save()">保存</button>
</div>
<script type="text/javascript">
	function save(){
		$.post('{$config["admin_route"]}core/configvalue',$('form').serialize(),function(res){
			if(res.code>0){
				layer.msg(res.msg,{'icon':2});
			}else{
				layer.msg(res.msg,{'icon':1});
				history.go(0);
			}
		},'json');
	}
</script>
{include file="public/tail" /}